<template>
  <div class="content-view-wrapper pd-10 business-execution">
    <div class="header">
      <div class="title">物流计划执行率</div>
      <div class="search-box">
        <el-tabs v-model="activeTab" class="tab-list">
          <el-tab-pane name="1" label="销售计划"> </el-tab-pane>
          <el-tab-pane name="2" label="采购计划"> </el-tab-pane>
        </el-tabs>
        <div class="search">
          <el-date-picker v-model="year" type="year" placeholder="选择年" :clearable="false" @change="yearChange">
          </el-date-picker>
          <el-select
            v-model="quarter"
            placeholder="请选择季度"
            style="margin: 0 10px"
            @change="quarterChange"
          >
            <el-option
              v-for="item in quarterOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-select v-model="month" placeholder="请选择月" @focus="monthFocus" @change="monthChange">
            <el-option
              v-for="item in monthOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
      </div>
    </div>
    <div class="business-content">
      <SalesPlan v-if="activeTab==='1'"></SalesPlan>
      <PurchasingPlan v-if="activeTab==='2'"></PurchasingPlan>
    </div>
  </div>
</template>

<!--业务执行-->
<script>
import moment  from 'moment'
import SalesPlan from "./salesPlan.vue";
import PurchasingPlan from "./purchasingPlan.vue";
import {getMonths, quarters} from "./hooks";
export default {
  name: "businessExecution",
  components: { SalesPlan, PurchasingPlan },
  data() {
    return {
      activeTab: "1",
      year: moment().format("YYYY"),
      month: "",
      quarter: "",
      quarterOptions: quarters,
      monthOptions: []
    };
  },
  methods: {
    monthFocus() {
      if(!this.quarter){
        this.$message.warning("请先选择季度")
        return
      }
      this.monthOptions=getMonths(this.quarter)
    },
    yearChange(){},
    quarterChange(){
      this.month=""
      this.monthOptions=getMonths(this.quarter)
    },
    monthChange(){}
  },
};
</script>

<style scoped lang="scss">
.business-execution {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: auto;
  --container-padding: 20px;
  .header {
    background-color: #fff;
    margin-bottom: 10px;
    padding: var(--container-padding);
    display: flex;
    flex-direction: column;
    .title {
      font-size: 20px;
      margin-bottom: 10px;
    }
    .search-box {
      display: flex;
      justify-content: space-between;
      .tab-list {
        margin-bottom: -20px;
      }
    }
  }
  .business-content {
    flex: 1;
    padding: var(--container-padding);
    background-color: #fff;
  }
}
</style>
